package com.example.practicespring.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.io.File;

import static com.example.practicespring.ConstantConfig.ConstantConfig.imgPath;

@Component
public class SystemInit implements CommandLineRunner {

    private static final Logger log = LoggerFactory.getLogger(SystemInit.class);

    @Override
    public void run(String... args) throws Exception {
        try {
            File file = new File(imgPath);
            if (file.exists()) return;
            if (!file.mkdirs()) throw new RuntimeException("头像存储文件夹初始化异常");
        } catch (Exception e) {
            log.error("头像存储文件夹初始化异常", e);
        }
    }

    // @Order(1)
    // public static class AA implements ApplicationRunner {
    //     @Override
    //     public void run(ApplicationArguments args) throws Exception {
    //
    //     }
    //     // SystemInit2
    // }
    //
    // public static class BB implements CommandLineRunner {
    //
    //     @Override
    //     public void run(String... args) throws Exception {
    //
    //     }
    // }
    //
    // public static class CC {
    //
    // }
}
